package com.example.cslp.service.Impl;

/**
 * @author zcy
 */
import com.example.cslp.mapper.RecordMapper;
import com.example.cslp.pojo.entity.Course;
import com.example.cslp.pojo.entity.Record;
import com.example.cslp.service.CommentService;
import com.example.cslp.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Service
public class RecordServiceImpl implements RecordService {
    //    @Autowired
//    RecordMapper recordMapper;
//    //增加选课记录
//    public ResponseEntity<Boolean> addRecord(Record record){
//        return ResponseEntity.ok(recordMapper.addRecord(record));
//    }
    @Autowired
    RecordMapper recordMapper;
    CommentService commentService;
    //增加选课记录
    public Boolean addRecord(Record record){

        return recordMapper.addRecord(record);
    }

    @Override
    public ResponseEntity<Boolean> delRecord(String u_id, String c_id) {
        return ResponseEntity.ok(recordMapper.delRecord(u_id, c_id));
    }

    //根据用户获取选课信息
    @CrossOrigin
    public List<Course> getRecordByUser(String name){
        return recordMapper.getRecordByUser(name);
    }

    //获取用户没有选的课
    public List<Course> getUnRecordByUser(String name){
        return recordMapper.getUnsubscribedCoursesByUser(name);
    }
    //支付
    public Boolean payPoints(Record record){
        return recordMapper.payPoints(record);
    }
}
